import http from '../../utils/http.js'

export function getHomeConfig() {
	return new Promise((resolve, reject) => {
		var params = {
			url: '/v1/app/home/index',
			method: 'GET',
			data: {},
			callBack: (res) => {
				if (res.code == 0) {
					resolve(res)
				} else {
					reject(res.msg)
				}
			}
		}
		http.request(params)
	})
}

export function getChargeScan(shellId) {
	return new Promise((resolve, reject) => {
		var params = {
			url: '/v1/app/charging/scan',
			method: 'GET',
			data: {
				shellId: shellId
			},
			callBack: (res) => {
				if (res.code == 0) {
					resolve(res)
				} else {
					reject(res.msg)
				}
			}
		}
		http.request(params)
	})
}

export function checkVersionUpdate() {
	return new Promise((resolve,reject)=>{
		plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
			const res = uni.getSystemInfoSync();
			const system = res.platform;
			var params = {
				url: '/v1/system/get/app/version',
				method: 'GET',
				data: {
					plat: system == 'ios' ? 'iOS' : 'android',
					appType: 0,
					appVersion: wgtinfo.version
				},
				callBack: (res) => {
					if (res.code == 0) {
						resolve(res)
					} else {
						reject(res.msg)
					}
				}
			}
			http.request(params)
		})
	})
}

export function getPopUpInfo(){
	return new Promise((resolve,reject)=>{
	    var params={
		   url:'/v1/activity/list',
		   method:'GET',
		   data:{
			   source: 1
		   },
		   callBack:(res)=>{
			if(res.code==0){
			 resolve(res)
			}
			else{
			 reject(res.msg)
			}
		}
	  }
	  http.request(params)
	})
}
